<!--公共必要的JS-->
<script src="/static/check.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/layui/layui.all.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/globals.js"></script>

<!--省市区-->
<script src="/static/shengshiqu/distpicker.data.js"></script>
<script src="/static/shengshiqu/distpicker.js"></script>

<!--编辑器开始-->
<script src="/static/ueditor/ueditor.config.js"></script>
<script src="/static/ueditor/ueditor.all.js"></script>
<script>
    $(function () {
        //循环实例化编辑器
        $(".news_editor").each(function(){
            var editor_name=$(this).attr("editor_name");
            var editor_width=$(this).attr("editor_width");
            var editor_height=$(this).attr("editor_height");
            var imgwidth=$(this).attr("imgwidth");
            var imgheight=$(this).attr("imgheight");
            var ue = UE.getEditor(editor_name, {
                initialFrameHeight: editor_height>0?editor_height:"0",
                initialFrameWidth: editor_width>0?editor_width:'100%',
				zIndex:1,
                imgwidth: imgwidth,
                imgheight: imgheight,
            });
            //启用抓取微信文章功能
            if(editor_name=="newstext"){
                $(".subWxCrawler").show();
            }
        })

    })
</script>
<!--编辑器结束-->
<!---百度地图-->
<script type="text/javascript" src="/static/baidumap/setpoint.js"></script>
<script>
    $(".baidu_map_field").each(function(){
        var baidu_map=new baidumap();
        baidu_map.map_search_value_id=$(this).find(".map_search_value").attr("id");
        baidu_map.map_search_button_id=$(this).find(".map_search_button").attr("id");
        baidu_map.map_field_id=$(this).find(".map_point").attr("id");
        baidu_map.map_show_id=$(this).find(".map_show").attr("id");
        baidu_map.showPoint=0;//如果修改信息的话需要显示之前的标记，这里请设置1  增加信息设置0
        //启动地图显示区方法
        baidu_map.newmap();
        //启动地址模糊搜索方法
        baidu_map.map_search();
        //启动鼠标点击拾取坐标方法
        baidu_map.map_position();
    })
</script>

<!--文件上传 start-->
<script type="text/javascript" src="/static/webuploader/kinderfile.js"></script>
<script type="text/javascript" src="/static/webuploader/Sortable.js"></script>
<script type="text/javascript" src="/static/webuploader/morepic.js"></script>


<!--以下是针对 快速上传单个文件插件-->
<link rel="stylesheet" type="text/css" href="/static/webuploader/style/webuploader.css" />
<link rel="stylesheet" type="text/css" href="/static/webuploader/style/style.css" />
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/static/webuploader/fastupimg.js"></script>
<!--文件上传 end-->
<!--文件上传的预览功能中中也需要用到我 fancybox plus start-->
<link rel="stylesheet" type="text/css" href="/static/fancybox/jquery.fancybox-1.3.4.vot.css" media="screen" />
<script type="text/javascript" src="/static/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="/static/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<!--文件上传的预览功能中中也需要用到我 fancybox plus end-->


  <!--select2 js start-->
  <link rel="stylesheet" href="/static/select2/select2.css" media="all">
  <script src="/static/select2/select2.js"></script>
  <!--select2 js end-->
<script>
    $(function(){
        $(".thischeck_all").click(function(){
            var y=$(this).attr("val");
            var objname=$(this).attr("objname");
            if(y==0){
                $("."+objname).prop("checked", false);
                y=1;
            }else if(y==1){
                $("."+objname).prop("checked", true);
                y=0;
            }
            $(this).attr("val",y);
        })
    })

    //排序
    function update_order(obj,inputname){
        $("input[name='"+inputname+"']").val($(obj).val());
    }
    let form = '';
//layer
  layui.use([ 'form', 'laydate'], function(){
    var $ = layui.$
	,laydate = layui.laydate;
    form = layui.form;
	//时间控件
	$(".form-date").each(function(){
		let dataFormat=$(this).data("format");
		let type = $(this).data('type');
		dataFormat=dataFormat?dataFormat:"yyyy-MM-dd";
		type = type ? type : 'date'
		laydate.render({
          type: type,
		  elem:this,
		  calendar: true,
          trigger: 'click',
		  format: dataFormat //可任意组合
		});
	});

    $(".form-time").each(function(){
      let dataFormat=$(this).data("format");
      let type = $(this).data('type');
      dataFormat=dataFormat?dataFormat:"yyyy-MM-dd HH:mm:ss";
      type = type ? type : 'datetime'
      laydate.render({
        type: type,
        elem:this,
        calendar: true,
        trigger: 'click',
        format: dataFormat //可任意组合
      });
    });

	$('.select2').select2();
  })
//模型切换
function urlgo(obj){
  $val=$(obj).val();
  window.location.href='/admin/Cat/add.html?modelid='+$val;
}

//多值字段
function morevalue_add(obj,str){
    var randStr2=randStr();
    for (var i=0; i<30;i++){
        //一次替换三次randImgId，因为一个上传窗口需要替换id="randImgId" 和button里的selectfile('randImgId','','img','','')
        if(i%3==0){
            randStr2=randStr();
        }
        str = str.replace('randImgId',"img_"+randStr2);
        str = str.replace('randFileId',"file_"+randStr2);
        str = str.replace('randVideoId',"video_"+randStr2);
    }
    $(obj).parents("tr").after(str);
}
function morevalue_del(obj){
    var len=$(obj).parents("tbody").children().length;
    if(len==1){
            alert("至少要保留一行数据");
            return false;
    }
    $(obj).parents("tr").remove();
}
//多值-图片预览
function morevaluePreImg(id){
    var src=$("#"+id).val();
    $.fancybox({href:src});
}
//多值-文件预览
function morevaluePreFile(id){
    var src=$("#"+id).val();
    window.open(src);
}
//多值-视频预览
function morevaluePreVideo(id){
    var src=$("#"+id).val();
	if(src){
            $.fancybox({
                    content:'<div class="fancybox_video_play"><video  style="width:800px;height:auto" id="fancybox_video_src" src="'+src+'" autoplay controls></video></div>',
            })
	}else{
            layer.msg("视频路径为空");
	}
}
//多值-textarea点击放大的效果
function moreBigTextarea(obj,type){
    layer.prompt({
        title:"内容编辑区域",
        formType: type,//1, //输入框类型，支持0（文本）默认1（密码）2（多行文本）
        area: ['400px', '240px'],
        value: $(obj).val(),
        btn:['确认']
    },function(value, index, elem){
        $(obj).val(value);
        layer.close(index);
    });
}
  </script>
